package com.shzg.im.model;

import java.sql.Date;
import java.text.SimpleDateFormat;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

public class Message {

    private String id;

    private String fromUserId;

    private String toDestId;

    private String messageContent;

    @DateTimeFormat(iso = ISO.DATE_TIME)
    private Date sendTime;

    private Date readTime;

    private int readFlag;

    private int messageType;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMessageContent() {
        return messageContent;
    }

    public void setMessageContent(String messageContent) {
        this.messageContent = messageContent;
    }

    public Date getSendTime() {
        return sendTime;
    }

    @DateTimeFormat(iso = ISO.DATE_TIME)
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public Date getReadTime() {
        return readTime;
    }

    public void setReadTime(Date readTime) {
        this.readTime = readTime;
    }

    public int getReadFlag() {
        return readFlag;
    }

    public void setReadFlag(int readFlag) {
        this.readFlag = readFlag;
    }

    public String getFromUserId() {
        return fromUserId;
    }

    public void setFromUserId(String fromUserId) {
        this.fromUserId = fromUserId;
    }

    private SimpleDateFormat sdf = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss.SSS");

    @Override
    public String toString() {
        return String
                .format("Message [id=%s, fromUserId=%s, toDestId=%s, messageContent=%s, sendTime=%s, readTime=%s, readFlag=%s, messageType=%s]",
                        id, fromUserId, toDestId, messageContent,
                        sdf.format(sendTime), readTime, readFlag, messageType);
    }

    public String getToDestId() {
        return toDestId;
    }

    public void setToDestId(String toDestId) {
        this.toDestId = toDestId;
    }

    public int getMessageType() {
        return messageType;
    }

    public void setMessageType(int messageType) {
        this.messageType = messageType;
    }

}
